Visualizing `A++`, `A--`, `++A`, `--A` and their subtle differences.
In **postfix** operations, the *original* value of the variable is returned first, and then the variable is incremented or decremented. The value of the expression is the value *before* the change.
let x = 5; let y = x++; // y is 5, x is 6
Initial `valueA`:
Expression: `result = valueA++`
Result of expression:
Final `valueA`:
Initial `valueB`:
Expression: `result = valueB--`
Result of expression:
Final `valueB`:
In **prefix** operations, the variable is incremented or decremented *first*, and then its *new* value is returned. The value of the expression is the value *after* the change.
let x = 5; let y = ++x; // y is 6, x is 6
Initial `valueC`:
Expression: `result = ++valueC`
Result of expression:
Final `valueC`:
Initial `valueD`:
Expression: `result = --valueD`
Result of expression:
Final `valueD`: